import asyncio

async def long_task():
    await asyncio.sleep(10)
    return "done"

async def main():
    try:
        res = await asyncio.wait_for(long_task(), timeout=2)
        print(res)
    except asyncio.TimeoutError:
        print("task timeout!")

asyncio.run(main())